﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    public class Program
    {
        static void Main(string[] args)
        {
            int result = add(2, 3);
            IntPtr ptr= GetTestData();
            var a = (TestData)Marshal.PtrToStructure(ptr, typeof(TestData));
            var testData = new TestData();
            GetTestDataRef(ref testData);
            Console.ReadKey();

        }
        [DllImport("TestDll.dll")]
        public static extern int add(int a,int b);

        [DllImport("TestDll.dll")]
        public static extern IntPtr GetTestData();

        [DllImport("TestDll.dll")]
        public static extern void GetTestDataRef(ref TestData testData);
    }

    [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    [Serializable]
    public struct TestData
    {
        public int a;

        public int b;

        public int c;
    }


}
